//
//  HLMatchTipView.m
//  YueYue
//
//  Created by hulu001 on 2023/8/25.
//

#import "HLMatchTipView.h"

@interface HLMatchTipView ()

@property (nonatomic, strong) UIImageView *backView;
@property (nonatomic, strong) UIImageView *iconView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) QMUIButton *closeButton;
@property (nonatomic, strong) UIView *containerView;
@property (nonatomic, strong) UITapGestureRecognizer *tapGesture;
@property (nonatomic, strong) UILabel *detailLabel;

@end

@implementation HLMatchTipView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    self.backView = [[UIImageView alloc] initWithImage:UIImageMake(@"rtc_match_tip_back")];
    [self addSubview:_backView];
    [_backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
    
    self.iconView = [[UIImageView alloc] initWithImage:UIImageMake(@"rtc_match_tip_icon")];
    [self addSubview:_iconView];
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(0);
    }];
    
    
    self.closeButton = [[QMUIButton alloc] init];
    [_closeButton setImage:UIImageMake(@"rtc_match_tip_close") forState:UIControlStateNormal];
    [_closeButton addTarget:self action:@selector(closeAction) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_closeButton];
    [_closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(18);
        make.top.mas_equalTo(3);
        make.right.mas_equalTo(-3);
    }];
    
    self.titleLabel = [[UILabel alloc] qmui_initWithFont:UIFontMake(13) textColor:UIColorWhite];
    _titleLabel.text = @"对TA心动了吗？";
    [self addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(16);
    }];
    
    self.containerView = [[UIView alloc] init];
    _containerView.backgroundColor = UIColorWhite;
    _containerView.layer.masksToBounds = YES;
    _containerView.layer.cornerRadius = 8;
    [self addSubview:_containerView];
    [_containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.right.mas_equalTo(-12);
        make.height.mas_equalTo(36);
        make.top.equalTo(_titleLabel.mas_bottom).offset(8);
    }];
    
    self.tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
    [_containerView addGestureRecognizer:_tapGesture];
    
    self.detailLabel = [[UILabel alloc] qmui_initWithFont:UIFontMediumMake(13) textColor:HLMainColor];
    _detailLabel.text = @"继续聊天";
    [_containerView addSubview:_detailLabel];
    [_detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(2);
    }];
    
    self.priceView = [[QMUIButton alloc] init];
    [_priceView setImage:UIImageMake(@"home_flow_coin") forState:UIControlStateNormal];
    [_priceView setTitle:@"99/30秒" forState:UIControlStateNormal];
    [_priceView setTitleColor:[HLMainColor colorWithAlphaComponent:0.6] forState:UIControlStateNormal];
    _priceView.titleLabel.font = UIFontMake(10);
    _priceView.imagePosition = QMUIButtonImagePositionLeft;
    _priceView.spacingBetweenImageAndTitle = 2;
    [_containerView addSubview:_priceView];
    [_priceView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.bottom.mas_equalTo(-2);
    }];
    
}

- (void)tapAction
{
    if (self.callback){
        self.callback(YES);
    }
}

- (void)closeAction
{
    self.hidden = YES;
}
@end
